package com.example.spareparts.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.spareparts.entity.InventoryAdjustments;
import com.example.spareparts.service.InventoryAdjustmentsService;
import java.util.List;

@RestController
@RequestMapping("/api/inventoryadjustments")
public class InventoryAdjustmentsController {
    @Autowired
    private InventoryAdjustmentsService inventoryAdjustmentsService;
    @GetMapping ("/listall")
    public List<InventoryAdjustments> findAllInventoryAdjustments()
    {
        return inventoryAdjustmentsService.findAllInventoryAdjustments();
    }
    @PostMapping ("/insert")
    public void insertInventoryAdjustments(@RequestBody InventoryAdjustments inventoryAdjustments){
        inventoryAdjustmentsService.insertInventoryAdjustments(inventoryAdjustments);
    }
    @PutMapping ("/update/{adjustmentid}")
    public void updateInventoryAdjustments(@PathVariable Long adjustmentid, @RequestBody InventoryAdjustments inventoryAdjustments){
        inventoryAdjustments.setAdjustmentid(adjustmentid);
        inventoryAdjustmentsService.updateInventoryAdjustments(inventoryAdjustments);
    }
    @DeleteMapping ("/delete/{adjustmentid}")
    public void deleteInventoryAdjustments(@PathVariable Long adjustmentid){
        inventoryAdjustmentsService.deleteInventoryAdjustments(adjustmentid);
    }
    @GetMapping ("/findbyid/{adjustmentid}")
    public InventoryAdjustments findInventoryAdjustmentsById(@PathVariable Long adjustmentid){
        return inventoryAdjustmentsService.findInventoryAdjustmentsById(adjustmentid);
    }
    @GetMapping ("/findbysparepartid/{sparepartid}")
    public List<InventoryAdjustments> findInventoryAdjustmentsBySparePartId(@PathVariable Long sparepartid){
        return inventoryAdjustmentsService.findInventoryAdjustmentsBySparePartId(sparepartid);
    }
}
